import { fromJS } from 'immutable';
import * as constants from './constants';

const defaultState = fromJS({
  dialogVisible: false,
  settingsData: []
});

export default (state = defaultState, action) => {
  switch(action.type) {
    case constants.GET_SETTINGSDATA:
      return state.set("settingsData", fromJS(action.settingsData));
    case constants.OPEN_EDITPANEL:
      return state.set("dialogVisible", action.dialogVisible);
    case constants.CLOSE_EDITPANEL:
      return state.set("dialogVisible", action.dialogVisible);
    case constants.GET_PANELDATA:
      return state.set("dialogVisible", action.dialogVisible);
    default:
      return state;
  }
}